<?php

/**
 * @author Walter Tamboer
 */

/**
 * Gets information from the URL.
 */
class UriHelper extends Helper
{
	/**
	 * GetSegment
	 *
	 * @author Walter Tamboer
	 * @since 24 aug 2006
	 * @param int $number The segment
	 */
	public function GetSegment($number)
	{
		// It must be a number
		$number = intval($number);
		
		// Always decrease
		$number--;
		
		// Must at least be zero
		if ($number < 0)
			$number = 0;

		$PathInfo = $_SERVER[ 'PATH_INFO' ];

		$e = explode('/', $PathInfo);

		array_shift($e); // Skip the empty element
		array_shift($e); // Skip the controller
		array_shift($e); // Skip the function

		return isset($e[$number]) ? $e[$number] : null;
	}
}

?>